package servlets;
 import java.io.*;
 import javax.servlet.*;
 import javax.servlet.http.*;

  public class MulServlet extends HttpServlet
   {
      
     public void init(ServletConfig config) throws ServletException
    {
       super.init(config);
       
     }
 
     protected void doGet(HttpServletRequest req,
                          HttpServletResponse res)
               throws ServletException, IOException
     {
         
         
       res.setContentType("text/html");
       res.setHeader("pragma", "no-cache");
       PrintWriter out = res.getWriter();
       out.print("<HTML><HEAD><TITLE>Enter the multipliers</TITLE></HEAD>");
       out.print("<FORM METHOD=POST>");
       out.print("Enter the first multiplier: <INPUT TYPE=TEXT NAME=mul1><BR>");
       out.print("Enter the second multiplier: <INPUT TYPE=TEXT NAME=mul2><BR>");
       out.print("<INPUT TYPE=SUBMIT NAME=submit VALUE=\"Submit\">");
       out.print("</FORM></BODY></HTML>");
       out.close();
     }
 
     protected void doPost(HttpServletRequest req,
                           HttpServletResponse res)
               throws ServletException, IOException
     {
      String mul1 = req.getParameter("mul1");
      String mul2 = req.getParameter("mul2");
      int a = Integer.parseInt(mul1);
      int b = Integer.parseInt(mul2);
      int result = a*b;
       res.setContentType("text/html");
       res.setHeader("pragma", "no-cache");
       PrintWriter out = res.getWriter();
	  out.print("<HTML><HEAD><TITLE>result of multiply</TITLE></HEAD><BODY>result:");
       out.print(result);
       out.print("</BODY></HTML>");
       out.close();
     }
 
     public String getServletInfo()
    {
      return "MulServlet by Sasha";
    }

    

  }